// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ingest
{
	public sealed partial class InferenceConfigRegression : IInferenceConfigVariant
	{
		[JsonInclude]
		[JsonPropertyName("num_top_feature_importance_values")]
		public int? NumTopFeatureImportanceValues { get; set; }

		[JsonInclude]
		[JsonPropertyName("results_field")]
		public Elastic.Clients.Elasticsearch.Field? ResultsField { get; set; }
	}

	public sealed partial class InferenceConfigRegressionDescriptor<TDocument> : SerializableDescriptorBase<InferenceConfigRegressionDescriptor<TDocument>>
	{
		internal InferenceConfigRegressionDescriptor(Action<InferenceConfigRegressionDescriptor<TDocument>> configure) => configure.Invoke(this);
		public InferenceConfigRegressionDescriptor() : base()
		{
		}

		private int? NumTopFeatureImportanceValuesValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field? ResultsFieldValue { get; set; }

		public InferenceConfigRegressionDescriptor<TDocument> NumTopFeatureImportanceValues(int? numTopFeatureImportanceValues)
		{
			NumTopFeatureImportanceValuesValue = numTopFeatureImportanceValues;
			return Self;
		}

		public InferenceConfigRegressionDescriptor<TDocument> ResultsField(Elastic.Clients.Elasticsearch.Field? resultsField)
		{
			ResultsFieldValue = resultsField;
			return Self;
		}

		public InferenceConfigRegressionDescriptor<TDocument> ResultsField<TValue>(Expression<Func<TDocument, TValue>> resultsField)
		{
			ResultsFieldValue = resultsField;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (NumTopFeatureImportanceValuesValue.HasValue)
			{
				writer.WritePropertyName("num_top_feature_importance_values");
				writer.WriteNumberValue(NumTopFeatureImportanceValuesValue.Value);
			}

			if (ResultsFieldValue is not null)
			{
				writer.WritePropertyName("results_field");
				JsonSerializer.Serialize(writer, ResultsFieldValue, options);
			}

			writer.WriteEndObject();
		}
	}

	public sealed partial class InferenceConfigRegressionDescriptor : SerializableDescriptorBase<InferenceConfigRegressionDescriptor>
	{
		internal InferenceConfigRegressionDescriptor(Action<InferenceConfigRegressionDescriptor> configure) => configure.Invoke(this);
		public InferenceConfigRegressionDescriptor() : base()
		{
		}

		private int? NumTopFeatureImportanceValuesValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field? ResultsFieldValue { get; set; }

		public InferenceConfigRegressionDescriptor NumTopFeatureImportanceValues(int? numTopFeatureImportanceValues)
		{
			NumTopFeatureImportanceValuesValue = numTopFeatureImportanceValues;
			return Self;
		}

		public InferenceConfigRegressionDescriptor ResultsField(Elastic.Clients.Elasticsearch.Field? resultsField)
		{
			ResultsFieldValue = resultsField;
			return Self;
		}

		public InferenceConfigRegressionDescriptor ResultsField<TDocument, TValue>(Expression<Func<TDocument, TValue>> resultsField)
		{
			ResultsFieldValue = resultsField;
			return Self;
		}

		public InferenceConfigRegressionDescriptor ResultsField<TDocument>(Expression<Func<TDocument, object>> resultsField)
		{
			ResultsFieldValue = resultsField;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (NumTopFeatureImportanceValuesValue.HasValue)
			{
				writer.WritePropertyName("num_top_feature_importance_values");
				writer.WriteNumberValue(NumTopFeatureImportanceValuesValue.Value);
			}

			if (ResultsFieldValue is not null)
			{
				writer.WritePropertyName("results_field");
				JsonSerializer.Serialize(writer, ResultsFieldValue, options);
			}

			writer.WriteEndObject();
		}
	}
}